package main

import (
	"database/sql"
	_ "github.com/go-sql-driver/mysql"
	"github.com/gorilla/mux"
	"learnfans/app/http/middlewares"
	"learnfans/bootstrap"
	"learnfans/config"
	"learnfans/pkg/database"
	c "learnfans/pkg/config"
	"net/http"
)

//解决变量作用于引起的变量未找到问题
var router = mux.NewRouter()
var db *sql.DB

func init() {
	// 初始化配置信息
	config.Initialize()
}

func main() {

	database.Initialize()
	db = database.DB

	bootstrap.SetupDB()
	router = bootstrap.SetupRoute()

	//http.ListenAndServe(":3000", middlewares.RemoveTrailingSlash(router))
	http.ListenAndServe(":"+c.GetString("app.port"), middlewares.RemoveTrailingSlash(router))
}
